package cn.taskservice.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ResultCode {
    SUCCESS(200, "操作成功"),
    FAIL(500, "操作失败"),
    PARAM_ERROR(400, "参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    SERVER_ERROR(500, "服务器内部异常"),
    // 参数校验
    VALIDATE_FAILED(1001, "参数校验失败"),

    // 业务错误 2xxx
    BUSINESS_ERROR(2000, "业务异常"),

    // 用户相关 21xx
    USER_NOT_FOUND(2101, "用户不存在"),
    USER_FORBIDDEN(2102, "用户无权限"),

    // 远程调用相关 22xx
    REMOTE_CALL_FAIL(2200, "远程服务调用失败"),

    // 数据库相关 23xx
    DB_ERROR(2300, "数据库异常"),

    // 技术异常 3xxx
    NULL_POINTER(3001, "空指针异常"),
    CLASS_CAST(3002, "类型转换异常"),
    IO_ERROR(3003, "IO异常"),
    SQL_ERROR(3004, "SQL异常"),
    TIMEOUT(3005, "系统超时"),
    UNKNOWN_ERROR(3999, "未知异常");

    private final int code;
    private final String message;

    public int code() {
        return code;
    }

    public String message() {
        return message;
    }
}
